<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>OAUTH2统一认证</title>

    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/signin.css" rel="stylesheet">
</head>

<body>
<div class="container form-margin-top">
    <form class="form-signin" id="login_form">
        <h2 class="form-signin-heading" align="center">统一认证系统</h2>
        <input type="text" name="username" class="form-control form-margin-top" placeholder="账号" required autofocus value="admin">
        <br/>
        <input type="password" name="password" class="form-control" placeholder="密码" required value="123456">
        <input type="text" name="captchaCode" class="form-control mt-20 mb-20 w-half" placeholder="验证码" required value="1234">
        <div style="background-color: #1b6d85;margin: -58px 0 0 192px;height: 30px;width: 70px;padding-top: 5px;text-align: center;">
            <span style="font-size: 16px;">1 2 3 4</span>
        </div>
        <div style="margin-top: 30px;height: 30px;width: 70px;">
            <input type="checkbox" checked="checked" name="rememberMe" class="checkbox" id="checkbox" value="1" >
            <label style="margin-top: -51px;display: inline-block;vertical-align: middle;" for="checkbox">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;记住我</label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
    </form>
</div>
<!--    <footer>
        <p></p>
        <p></p>
    </footer>-->

<script type="text/javascript" src="/js/jquery-1.12.4.js"></script>
<script type="text/javascript">
    $('#login_form').on('submit', function (e) {
        e.preventDefault();
        login_fn();
    });
    function login_fn() {
        console.info("++++++", $("input[name='username']").val());
        $.ajax({
            url: '/authentication/require',
            type: 'POST',
            data: {
                username: $("input[name='username']").val(),
                password: $("input[name='password']").val(),
                captchaCode: $("input[name='captchaCode']").val(),
                rememberMe: $("input[name='rememberMe']").is(":checked")
            },
            success: function (data, status) {
                console.info("asdfsd", data);
                if (data.code == 1000) {
                    window.location.href = '/'
                } else {
                    alert(data.message);
                }
            }
        });
    }

</script>

</body>
</html>
